/**
  * @(#)Instructor.java 
  *
  * Store the instructor information for a section
  *
  * @author Course Scheduler Team
  * 
  * @license GNU General Public License version 3 (GPLv3)
  *
  * This file is part of Course Scheduler, an open source, cross platform
  * course scheduling tool, configurable for most universities.
  *
  * Copyright (C) 2010-2012 Course Scheduler Team
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  * the Free Software Foundation, either version 3 of the License, or
  * (at your option) any later version.
  *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  * 
  */
package com.pollicitus.scheduler.model;

import java.util.HashMap;
import java.util.Map;

import com.pollicitus.scheduler.model.Instructor;

/**
 * Store instructor information for a section or university
 * 
 * @author Course Scheduler Team
 *
 */
public class Instructor {

	/**
	 * The most recent revision in which this file was changed in the source control system
	 */
	public static final String _revision = "$LastChangedRevision: 539 $";
	
	/**
	 * The date on which this file was last changed and submitted to source control
	 */
	public static final String _date = "$LastChangedDate: 2011-11-19 23:14:16 -0500 (Sat, 19 Nov 2011) $";
	
	/**
	 * The user which last changed the file and committed the change to source control
	 */
	public static final String _author = "$LastChangedBy: mike@pollicitus.com $";
	
	/**
	 * The URL which can be used to access this specific file within the source control system
	 */
	public static final String _headURL = "$HeadURL: https://courseschedulerx.googlecode.com/svn/trunk/course-scheduler/course-scheduler-core/src/main/java/com/pollicitus/scheduler/model/Instructor.java $";
	
	/**
	 * The source control file ID, comprised of the file name, latest revision, last changed date, and submitting user.
	 */
	public static final String _id = "$Id: Instructor.java 539 2011-11-20 04:14:16Z mike@pollicitus.com $";
	
	//private instructor fields
	private String firstName;
	private String middleName;
	private String lastName;
	private String department;
	private String university;
	private Map<String, Double> ratings;
	
	/**
	 * Construct a new Instructor instance using the specified names for the
	 * specified university.
	 * 
	 * @param firstName the instructor's first name
	 * @param middleName the instructor's middle name
	 * @param lastName the instructor's last name
	 * @param university the instructor's university
	 */
	public Instructor(String firstName, String middleName, String lastName, String university) {
		this.firstName = firstName;
		this.middleName = middleName;
		this.lastName = lastName;
		this.university = university;
		
		//build the ratings map
		ratings = new HashMap<String, Double>();
	}

	/**
	 * Return the department in which the instructor teaches
	 * 
	 * @return the instructor's department
	 */
	public String getDepartment() {
		return department;
	}

	/**
	 * Set the instructor's department
	 * 
	 * @param department the department to use
	 */
	public void setDepartment(String department) {
		this.department = department;
	}

	/**
	 * Return the instructor's rating 
	 * 
	 * @return the ratings
	 */
//	public static double getRating() {
//		return ratings;
//	}

	/**
	 * Set the instructor's rating
	 * 
	 * @param ratings the ratings to use
	 */
//	public static void setRating(double rating) {
//		Instructor.ratings = rating;
//	}

	
	/* (non-Javadoc)
	 * @see java.lang.Object#toString()
	 */
	@Override
	public String toString() {
		return lastName + ", " + firstName + " " + middleName;
	}

	/**
	 * Return the instructor's first name
	 * 
	 * @return the instructor's first name 
	 */
	public String getFirstName() {
		return firstName;
	}

	/**
	 * Return the instructor's middle name
	 * 
	 * @return the instructor's middle name
	 */
	public String getMiddleName() {
		return middleName;
	}

	/**
	 * Return the instructor's last name
	 * 
	 * @return the instructor's last name
	 */
	public String getLastName() {
		return lastName;
	}

	/**
	 * Return the university at which the instructor teaches
	 * 
	 * @return the university 
	 */
	public String getUniversity() {
		return university;
	}

	/**
	 * Set the university at which the instructor teaches
	 * 
	 * @param university the university to use
	 */
	public void setUniversity(String university) {
		this.university = university;
	}
	
	/* (non-Javadoc)
	 * @see java.lang.Object#equals(java.lang.Object)
	 */
	@Override
	public boolean equals(Object other){
		Instructor prof = (Instructor)other;
		
		//use the university and instructor name fields for comparison
		return prof.getUniversity().compareTo(this.getUniversity()) == 0 &&
				prof.getLastName().compareTo(this.getLastName()) == 0 &&
				prof.getFirstName().compareTo(this.getFirstName()) == 0 &&
				prof.getMiddleName().compareTo(this.getMiddleName()) == 0;
	}
	
	/* (non-Javadoc)
	 * @see java.lang.Object#hashCode()
	 */
	@Override
	public int hashCode(){
		//XOR the hashcodes of the equality fields
		return this.getUniversity().hashCode() ^
				this.getLastName().hashCode() ^
				this.getFirstName().hashCode() ^
				this.getMiddleName().hashCode();
	}
}
